package structure_结构性.filter_pattern_过滤器模式;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: hihi
 * @Date: 2020/07/07/10:07
 * @Description:
 */
public class OrFilter implements Filter {

	private Filter filterOne;
	private Filter filterTwo;

	public OrFilter(Filter filterOne, Filter filterTwo) {
		this.filterOne = filterOne;
		this.filterTwo = filterTwo;
	}

	/**
	 * @param people
	 * @return
	 */
	@Override public List<Person> filter(List<Person> people) {
		List<Person> people1 = filterOne.filter(people);
		List<Person> people2 = filterTwo.filter(people);
		people1.removeAll(people2);
		people1.addAll(people2);
		return people1;
	}
}
